package com.hxzon.netty.statistics.server;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;
import org.springframework.context.ApplicationContext;

public class StatisticsServerPipelineFactory implements ChannelPipelineFactory {
    private ApplicationContext spring;

    public StatisticsServerPipelineFactory(ApplicationContext spring) {
        this.spring = spring;
    }

    public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = Channels.pipeline();

        pipeline.addLast("decoder", new StringDecoder());
        pipeline.addLast("encoder", new StringEncoder());
        pipeline.addLast("handler", new StatisticsServerHandler(spring));

        return pipeline;
    }

}
